﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LyData.Data;
using System.Data;
using WebPublic;

public partial class Admin_JoinWord : System.Web.UI.Page
{
    protected void Bind()
    {
         Boolean b = (bool)this.Session["managerLogin"];
         if (!b)
         {
             ManagerLogin.Out();
         }
         else
         {
             IDb db = new DbFactory().DriverDb();
             db.Open();
             DataTable table = db.DataTable("*", "joinusmessage", "1=1", "ID DESC");
             db.Close();
             this.LeaveList.DataSource = table;
             this.LeaveList.DataBind();
         }
    }

    protected void FriendLinkList_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        this.LeaveList.PageIndex = e.NewPageIndex;
        this.Bind();
    }

    protected void FriendLinkList_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
    {
    }

    protected void FriendLinkList_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        HyperLink link = (HyperLink)e.Row.FindControl("EditHyperLink");
        Button button = (Button)e.Row.FindControl("DelBt");
        //if (button != null)
        //{
        //    if (!ManagerLogin.ValidateRole("C_FriendLinkEdit.aspx"))
        //    {
        //        link.Enabled = false;
        //    }
        //    if (!ManagerLogin.ValidateRole("C_FriendLinkList.aspx"))
        //    {
        //        button.Enabled = false;
        //    }
        //}
    }

    protected void FriendLinkList_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        int rowIndex = e.RowIndex;
        string str = this.LeaveList.DataKeys[rowIndex].Values[0].ToString();
        IDb db = new DbFactory().DriverDb();
        db.Open();
        db.Delete("joinusmessage", string.Format("ID={0}", str));
        db.Close();
        this.Bind();
        this.Msg.Text = "删除成功！";
        this.Msg.Visible = true;
    }

    protected void FriendLinkList_RowEditing(object sender, GridViewEditEventArgs e)
    {
    }

    protected void FriendLinkList_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        this.Msg.Visible = false;
        if (!base.IsPostBack)
        {
            this.Bind();
        }
    }
}
